home *** CD-ROM | disk | FTP | other *** search
- End-of-file rules
- Previous: <Multiple buffers=>Multiplebu> * Next: <Miscellaneous=>Miscellane> * Up: <Top=>!Root>
-
- #Wrap on
- {fH3}End-of-file rules{f}
-
- The special rule "<<EOF>>" indicates actions which are to
- be taken when an end-of-file is encountered and yywrap()
- returns non-zero (i.e., indicates no further files to
- process). The action must finish by doing one of four
- things:
-
- #Indent +4
-
- - assigning {fCode}yyin{f} to a new input file (in previous
- versions of flex, after doing the assignment you
- had to call the special action {fCode}YY\_NEW\_FILE{f}; this is
- no longer necessary);
-
-
- - executing a {fCode}return{f} statement;
-
-
- - executing the special {fEmphasis}yyterminate(){f} action;
-
-
- - or, switching to a new buffer using
- {fEmphasis}yy\_switch\_to\_buffer(){f} as shown in the example
- above.
-
- #Indent
-
- <<EOF>> rules may not be used with other patterns; they
- may only be qualified with a list of start conditions. If
- an unqualified <<EOF>> rule is given, it applies to {fEmphasis}all{f}
- start conditions which do not already have <<EOF>>
- actions. To specify an <<EOF>> rule for only the initial
- start condition, use
-
- #Wrap off
- #fCode
- <INITIAL><<EOF>>
- #f
- #Wrap on
-
- These rules are useful for catching things like unclosed
- comments. An example:
-
- #Wrap off
- #fCode
- %x quote
- %%
-
- …other rules for dealing with quotes…
-
- <quote><<EOF>> \{
- error( "unterminated quote" );
- yyterminate();
- \}
- <<EOF>> \{
- if ( \*++filelist )
- yyin = fopen( \*filelist, "r" );
- else
- yyterminate();
- \}
- #f
- #Wrap on
-
-